package com.carl.zeus.web.system;

import com.alibaba.fastjson.JSON;
import com.carl.zeus.common.base.BaseController;
import com.carl.zeus.server.system.SysLogService;
import com.carl.zeus.model.system.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 系统日志
 * 
 * @author zcm
 * @email 417449614@qq.com
 * @date 2017-03-08 10:40:56
 */
@Controller
@RequestMapping("/sys/log")
public class LogController extends BaseController {

	@Autowired
	private SysLogService sysLogService;
	
	/**
	 * 列表
	 */
	@RequestMapping("list")
	@RequiresPermissions("sys:log:list")
	public String list(){
		return "system/log";
	}

	//获取分页
	@RequestMapping(value="listAjax", method = RequestMethod.GET)
	@ResponseBody
	public String listAjax(@RequestParam(value = "page", defaultValue = "1") int page,
							  @RequestParam(value = "limit", defaultValue = "10") int limit,
							  @RequestParam(value = "key", defaultValue = "") String key,
							  @RequestParam(value = "value", defaultValue = "") String value) {
		Map<String, Object> map = new HashMap<>();
		List<SysLog> userList = sysLogService.listAjax(page, limit, key, value);
		map.put("code", 0);
		map.put("msg", "");
		map.put("count", sysLogService.countRoleList());
		map.put("data", userList);
		return JSON.toJSONString(map);
	}
	
}
